package sms_interface;

import java.io.IOException;

import junit.framework.TestCase;
/**
 * 
 * @author aayushjain
 *Junit functions for testing various classes
 */
public class TestVerify extends TestCase {
	/**
	 * Testing MessageVerification
	 */
	public void testverify() {
		MessageVerification mv = new MessageVerification();
		assertEquals(true,MessageVerification.verify("EN%3A%2DGet%20state%20f1%20l1%21Id%3A100%21"));
		assertEquals(false,MessageVerification.verify("EN%3A%2DDo%20state%20f1%20l1%21Id%3A100%21"));
		assertEquals(false,MessageVerification.verify("EN%3A%2DGet%20stats%20f1%20l1%21Id%3A100%21"));
		assertEquals(false,MessageVerification.verify("EN%3A%2DGet%20state%20f1%20l1%21I%3A100%21"));
		assertEquals(true,MessageVerification.verify("EN%3A%2DSet%20state%20ON%20f1%20l1%21Id%3A100%21"));
		assertEquals(true,MessageVerification.verify("EN%3A%2DGet%20data%20f1%20l1%205%20min%21Id%3A100%21"));
		assertEquals(false,MessageVerification.verify("EN%3A%2DGet%20data%20f1%20l1%2080%20min%21Id%3A100%21"));
		assertEquals(false,MessageVerification.verify("EN%3A%2DGet%20data%20f1%20l1%20t%20min%21Id%3A100%21"));
		assertEquals(false,MessageVerification.verify("EN%3A%2DGet%20data%20f1%20l1%207%20sec%21I%3A100%21"));
		assertEquals(false,MessageVerification.verify("EN%3A%2DGet%20data%20f1%20l1%209%20mi%21Id%3A100%21"));
		assertEquals(false,MessageVerification.verify("EN%3A%2DSet%20state%20abc%20f1%20l1%21Id%3A100%21"));
		assertEquals(false,MessageVerification.verify("EN%3A%2DSet%20stats%20OFF%20f1%20l1%21Id%3A100%21"));
		assertEquals(false,MessageVerification.verify("EN%3A%2DSet%20state%20ON%20f1%20l1%21I%3A100%21"));
		assertEquals(false,MessageVerification.verify("EN%3A%2DGet%20data%20f1%20l1%209%20min%21Id%3Aabc%21"));
		
	}
	/**
	 * Testing UserAuthentication
	 * @throws Exception
	 */
	public void testauthenticate() throws Exception{
		UserAuthentication ua=new UserAuthentication();
		assertEquals(true,UserAuthentication.authenticate("EN%3A%2DGet%20state%20f1%20l1%21Id%3A100%21","CR1"));
		assertEquals(false,UserAuthentication.authenticate("EN%3A%2DSet%20state%20ON%20f1%20l1%21Id%3A122%21","CR2"));
		assertEquals(false,UserAuthentication.authenticate("fbfhbj%20dfvh","cr3"));
		
	}
	
	/**
	 * Testing Sending_sms
	 * @throws Exception
	 */
	public void testSending_sms() throws Exception{
		Sending_sms sm=new Sending_sms();
		assertEquals(1,Sending_sms.get_authority("CR3","F2"));
	}
	
	/**
	 * Testing Sending_sms_mysql
	 * @throws Exception
	 */
	public void testSending_sms_mysql() throws Exception{
		Sending_sms_mysql sm=new Sending_sms_mysql();
		
		assertEquals(1,Sending_sms_mysql.get_authority("CR3","F2"));
	}
	
	/**
	 * Testing Get_sms
	 * @throws Exception
	 */
	public void testGet_sms() throws Exception{
		Get_sms sm=new Get_sms();
		
		//assert(Get_sms.receive_sms());
	}
}
